Crate wycheproof
source ·Expand description
§Wycheproof test vectors
Wycheproof is a set of cryptographic tests created by a team at Google which checks for common bugs and corner cases in cryptographic code.
This crate is a convenient repacking of the Wycheproof JSON-formatted test data with deserialization to easily usable structs.
Hex and base64 encoded data is decoded to binary in the BinaryString
struct which is a light wrapper around Vec<u8>
.
Large integers (such as those used in the RSA test data) are decoded as
big-endian byte arrays into a LargeInteger
struct, which is again a light
wrapper around Vec<u8>
. Additionally if the num-bigint
feature is enabled,
this type also gains a conversion function to num_bigint::BigUint
.
Each submodule of this crate includes a set of structs: a TestName
which
specifies which individual test is desired, a TestSet
which is the set of
data associated with the TestName
. Each TestSet
contains one or more
TestGroups
, which in turn contain some amount of test-specific
configuration information along with a list of Test
which are the actual
tests.
Each test has an expected result which is either Valid
, Invalid
, or
Acceptable
. Acceptable
just means that the test is technically valid but
might still be rejected for various reasons, for instance because the hash
function that was used is too weak for proper security.
§Examples
#[cfg(feature = "aead")]
fn print_gcm() {
// Print all AES-GCM test vector data
let test_set = wycheproof::aead::TestSet::load(wycheproof::aead::TestName::AesGcm).unwrap();
for test_group in test_set.test_groups {
println!(
"* Group key size:{} tag size:{} nonce size:{}",
test_group.key_size, test_group.tag_size, test_group.nonce_size,
);
for test in test_group.tests {
println!(
"Test:{} Key:{} AAD:{} PT:{} CT:{} Tag:{}",
test.tc_id,
data_encoding::HEXLOWER.encode(&test.key),
data_encoding::HEXLOWER.encode(&test.aad),
data_encoding::HEXLOWER.encode(&test.pt),
data_encoding::HEXLOWER.encode(&test.ct),
data_encoding::HEXLOWER.encode(&test.tag)
);
}
}
}
// Iterate over all of the AEAD tests
#[cfg(feature = "aead")]
for aead in wycheproof::aead::TestName::all() {
println!("{:?}", aead);
}
Modules§
- AEAD tests
- IND-CPA cipher tests
- DSA verification tests
- Elliptic Curve Information
- ECDH key agreement tests
- ECDSA tests
- EdDSA verification tests
- Format Preseverving Encryption
- Format Preseverving Encryption
- HKDF tests
- NIST keywrapping tests
- Message Authentication Code tests
- Message Authentication Code tests
- Primality checking tests
- RSA OAEP decryption tests
- RSA PKCS1v1.5 decryption tests
- RSA PKCS1v1.5 verification tests
- RSA PSS verification tests
- Montgomery curve ECDH tests
Structs§
Enums§
- Edwards curves
- Prime order elliptic curves
- Hash Function identifiers
- MGF identifiers
- Montgomery curves
- The expected result of a Wycheproof test
- The error type